using System;
using System.Collections.Generic;
using System.Text;

namespace SqlBlocks
{
	/// <summary>
	/// A container class for a particular database operation
	/// </summary>
	public class ItemOperation<T>
	{
		private T type;

		/// <summary>
		/// Gets the type of database operation
		/// </summary>
		public T Type
		{
			get { return type; }
		}

		private object opData = null;

		/// <summary>
		/// Creates a new database operation of the specified type
		/// </summary>
		/// <param name="type">The type of database operation</param>
		/// <param name="data">Data for the operation</param>
		public ItemOperation(T type, object data)
		{
			this.type = type;
			this.opData = data;
		}

		/// <summary>
		/// Gets a typed version of the operation data stored in this object
		/// </summary>
		/// <typeparam name="T">The requested type</typeparam>
		/// <returns>Typed data, if it matches T.  Null otherwise</returns>
		public K GetData<K>() where K : class
		{
			return this.opData as K;
		}
	}
}
